import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from 'path';
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";

const pathSrc = path.resolve(__dirname, "src");
// https://vitejs.dev/config/
export default defineConfig(() => {
    return {
        resolve: {
            alias: {
                "@": path.resolve(__dirname, "./src"),
            },
        },
        css:{
            preprocessorOptions:{
              less:{
                // additionalData:"import "+path.resolve(__dirname, "./styles/mixin.less"),
                //'@import "./src/assets/style/global.less";'
                additionalData:'@import "./src/styles/mixin.less";'
              },
              scss:{
                // additionalData:"import "+path.resolve(__dirname, "./styles/mixin.less"),
                //'@import "./src/assets/style/global.less";'
                additionalData:'@import "./src/styles/global_variables.module.scss";'
              }
            }
          },
        plugins: [
          vue(),
          createSvgIconsPlugin({
            // 指定需要缓存的图标文件夹
            iconDirs: [path.resolve(pathSrc, "assets/svg_icons")],
            // 指定symbolId格式,
            //这里dir为目录，如果是根目录的话为空，貌似只支持一级子目录
            //name为文件名
            symbolId: "icon-[dir]-[name]",
          }),
        ],
    };
});
